﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Songhay.Extensions;
using Songhay.Net;
using System;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Songhay.BiggestBox.Portable.Modules.ModelContext.Tests
{
    /// <summary>
    /// Tests for <see cref="IRestModelContextService"/>.
    /// </summary>
    [TestClass]
    public partial class IRestModelContextServiceTests
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        [TestInitialize]
        public void InitializeTest()
        {
            this.TestContext.RemovePreviousTestResults();
        }

        /// <summary>
        /// IRestModelContextService tests: should load earth tools XML.
        /// </summary>
        [TestMethod]
        [TestProperty("dumpPath", @"E:\~shares\dataRoot\Visual Studio 2012\Projects\Songhay.BiggestBox.Portable.Modules.ModelContext.Tests\RequestDumps\EarthToolsSunriseSunsetData.xml")]
        public void ShouldLoadEarthToolsXml()
        {
            var dumpPath = this.TestContext.Properties["dumpPath"].ToString();
            var xml = XDocument.Load(dumpPath);
            Assert.IsTrue(EarthToolsContext.InspectRemoteDocument(xml), "The expected XML document is not here)");

            var model = EarthToolsContext.GetEarthToolsSunriseSunsetModel(xml);
            Assert.IsNotNull(model, "The expected Earth Tools model is not here.");

            this.TestContext.WriteLine("Earth Tools model: {0}", model);
        }

        /// <summary>
        /// IRestModelContextService tests: should load noaa XML.
        /// </summary>
        [TestMethod]
        [TestProperty("dumpPath", @"E:\~shares\dataRoot\Visual Studio 2012\Projects\Songhay.BiggestBox.Portable.Modules.ModelContext.Tests\RequestDumps\NoaaWeather.xml")]
        public void ShouldLoadNoaaXml()
        {
            var dumpPath = this.TestContext.Properties["dumpPath"].ToString();
            var xml = XDocument.Load(dumpPath);
            Assert.IsTrue(NoaaWeatherContext.InspectRemoteDocument(xml), "The expected XML document is not here)");

            var model = NoaaWeatherContext.GetNoaaWeatherModel(xml);
            Assert.IsNotNull(model, "The expected NOAA model is not here.");

            this.TestContext.WriteLine("NOAA model: {0}", model);
        }
    }
}
